/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package struts.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import struts.Resource;
import struts.StrutsConfig;
import struts.StrutsPackage;
import struts.Transition;
import struts.WebApp;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Web App</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link struts.impl.WebAppImpl#getResources <em>Resources</em>}</li>
 *   <li>{@link struts.impl.WebAppImpl#getConfigXML <em>Config XML</em>}</li>
 *   <li>{@link struts.impl.WebAppImpl#getTransitions <em>Transitions</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class WebAppImpl extends EObjectImpl implements WebApp {
	/**
	 * The cached value of the '{@link #getResources() <em>Resources</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResources()
	 * @generated
	 * @ordered
	 */
	protected EList resources;

	/**
	 * The cached value of the '{@link #getConfigXML() <em>Config XML</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConfigXML()
	 * @generated
	 * @ordered
	 */
	protected StrutsConfig configXML;

	/**
	 * The cached value of the '{@link #getTransitions() <em>Transitions</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTransitions()
	 * @generated
	 * @ordered
	 */
	protected EList transitions;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected WebAppImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return StrutsPackage.Literals.WEB_APP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getResources() {
		if (resources == null) {
			resources = new EObjectContainmentEList(Resource.class, this, StrutsPackage.WEB_APP__RESOURCES);
		}
		return resources;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StrutsConfig getConfigXML() {
		return configXML;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetConfigXML(StrutsConfig newConfigXML, NotificationChain msgs) {
		StrutsConfig oldConfigXML = configXML;
		configXML = newConfigXML;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StrutsPackage.WEB_APP__CONFIG_XML, oldConfigXML, newConfigXML);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConfigXML(StrutsConfig newConfigXML) {
		if (newConfigXML != configXML) {
			NotificationChain msgs = null;
			if (configXML != null)
				msgs = ((InternalEObject)configXML).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StrutsPackage.WEB_APP__CONFIG_XML, null, msgs);
			if (newConfigXML != null)
				msgs = ((InternalEObject)newConfigXML).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StrutsPackage.WEB_APP__CONFIG_XML, null, msgs);
			msgs = basicSetConfigXML(newConfigXML, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StrutsPackage.WEB_APP__CONFIG_XML, newConfigXML, newConfigXML));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getTransitions() {
		if (transitions == null) {
			transitions = new EObjectContainmentEList(Transition.class, this, StrutsPackage.WEB_APP__TRANSITIONS);
		}
		return transitions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case StrutsPackage.WEB_APP__RESOURCES:
				return ((InternalEList)getResources()).basicRemove(otherEnd, msgs);
			case StrutsPackage.WEB_APP__CONFIG_XML:
				return basicSetConfigXML(null, msgs);
			case StrutsPackage.WEB_APP__TRANSITIONS:
				return ((InternalEList)getTransitions()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case StrutsPackage.WEB_APP__RESOURCES:
				return getResources();
			case StrutsPackage.WEB_APP__CONFIG_XML:
				return getConfigXML();
			case StrutsPackage.WEB_APP__TRANSITIONS:
				return getTransitions();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case StrutsPackage.WEB_APP__RESOURCES:
				getResources().clear();
				getResources().addAll((Collection)newValue);
				return;
			case StrutsPackage.WEB_APP__CONFIG_XML:
				setConfigXML((StrutsConfig)newValue);
				return;
			case StrutsPackage.WEB_APP__TRANSITIONS:
				getTransitions().clear();
				getTransitions().addAll((Collection)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case StrutsPackage.WEB_APP__RESOURCES:
				getResources().clear();
				return;
			case StrutsPackage.WEB_APP__CONFIG_XML:
				setConfigXML((StrutsConfig)null);
				return;
			case StrutsPackage.WEB_APP__TRANSITIONS:
				getTransitions().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case StrutsPackage.WEB_APP__RESOURCES:
				return resources != null && !resources.isEmpty();
			case StrutsPackage.WEB_APP__CONFIG_XML:
				return configXML != null;
			case StrutsPackage.WEB_APP__TRANSITIONS:
				return transitions != null && !transitions.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //WebAppImpl
